package list;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by Zhou_Bing on 2019/2/26.
 */
public class SortOfLinkedList {

    public static List<Integer> sSorted = new LinkedList();
    public static void addElement(int e){

        if(sSorted.size()==0){
            sSorted.add(e);
            return;
        }
        for(int i=0;i<sSorted.size();i++){
            if(e<sSorted.get(i)){
                sSorted.add(i,e);
                break;
            }
        }
    }

    public static void main(String args[]){

        addElement(3);
        System.out.println(sSorted);
        addElement(2);
        System.out.println(sSorted);
        addElement(1);
        System.out.println(sSorted);
        addElement(2);
        System.out.println(sSorted);

    }
}
